package homework1;

import java.io.File;

public class JavaFileFinder {
    
    public static void main(String[] args) {
        File directory = new File("E:\\课件保存处\\itheima-课程保存包");
        findJavaFiles(directory);
    }
    
    private static void findJavaFiles(File directory) {
        if (!directory.isDirectory()) {
            throw new IllegalArgumentException("给定路径不是一个目录");
        }
        
        File[] files = directory.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile() && file.getName().endsWith(".java")) {
                    System.out.println(file.getAbsolutePath());
                } else if (file.isDirectory()) {
                    findJavaFiles(file);
                }
            }
        }
    }
}